class_name Gold
extends Area2D

const SPEED=13

var canMove=false
var copy=false
var player


func _ready():
	position=Vector2(-500,-500)
	player=get_tree().get_first_node_in_group('player')

func _physics_process(_delta: float) -> void:
	move()


func move():
	if !player:
		return
	if canMove:
		var dir=(player.position-position).normalized()
		position+=dir*SPEED

# obj 从何处掉落 name 名称 position 
func create(options) -> void:
	if !options.has('obj'):
		options.obj=Main.actionNode
	var gold=duplicate()
	gold.copy=true
	options.obj.add_child(gold)
	gold.position=options.position



